package com.trump.baiduim.service.impl;

import com.trump.baiduim.dao.UserDao;
import com.trump.baiduim.model.User;
import com.trump.baiduim.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author xujb
 * @date 2020/11/24 13:59
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    public User queryUsernameIsExist(String useraccount) {

        User user = userDao.selectByUserAccount(useraccount);

        return user;
    }

    @Override
    public User queryUserForLogin(String username, String pwd) {
        return null;
    }

    @Override
    public void registerUser(User user) {
        userDao.insertSelective(user);
    }

    @Override
    public void updataInfo(User user) {

        userDao.updateByPrimaryKeySelective(user);
    }

    /**
     *
     *********
     */
    // 通过用户账号获取用户信息
    @Override
    public User findUserByUserAccountAndPassword(String userAccount,String userPassword) {

        return userDao.findUserByUserAccountAndPassword(userAccount,userPassword);
    }

    //更新/上传用户头像
    @Override
    public void uploadUserHeadPortrait(String userAccount, String userHeadPortrait, Date updateTime) {
        userDao.updateUserHeadPortrait(userAccount,userHeadPortrait,updateTime);
    }

    //用户登陆成功，将状态更新为登陆状态
    @Override
    public void updateUserStatus(String userAccount) {
        userDao.updateUserStatus(userAccount);
    }
}
